
import router from './router'
import Vue from 'vue';
import ElementUI from '../node_modules/element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import App from './App.vue'
import store  from './store';
import Cookie from 'cookiejs'

Vue.use(ElementUI,{ size: 'small', zIndex: 3000 })

Vue.config.productionTip = false

//导航守卫
router.beforeEach((to, from, next) => {
   //判断是否含有token，若没有，挑战到login页面
   const token = sessionStorage.getItem('token')
   if(!token){
      if(to.name=='login'){
          next()
      }else if(to.name=='register'||to.name=='register2'){
         next()
      }else{
        next({name:'login'})
      } 
   }else{
      //有token,但是也要判断不同角色对应的页面
      
      next()
   }
      
})


new Vue({
  
  store, //将store挂载到Vue实例上
  router,
  render: h => h(App)
}).$mount('#app')
